package com.fjnu.fjnu_grade_demo.controller;

import com.fjnu.fjnu_grade_demo.R;
import com.fjnu.fjnu_grade_demo.moudle.entity.StudentCourseGrade;
import com.fjnu.fjnu_grade_demo.moudle.entity.StudentTotalGrade;
import com.fjnu.fjnu_grade_demo.service.IStudentGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 学生成绩查询 控制器
 */
@RestController
@RequestMapping("/system/grade")
public class StudentGradeController{
    
    @Autowired
    private IStudentGradeService studentGradeService;
    
    /**
     * 根据学年和学期查询学生成绩
     */
    @GetMapping("/list")
    public R getGradesByAcademicYearAndSemester(
            @RequestParam(required = true) String studentId,
            @RequestParam(required = true) String academicYear,
            @RequestParam(required = true) String semester) {
        
        List<StudentCourseGrade> courseGradeList = studentGradeService.selectStudentCourseGradeList(studentId, academicYear, semester);
        List<StudentTotalGrade> totalGradeList = studentGradeService.selectStudentTotalGradeList(studentId, academicYear, semester);
        
        Map<String, Object> result = new HashMap<>();
        result.put("studentCourseGradeList", courseGradeList);
        result.put("studentTotalGradeList", totalGradeList);
        
        return R.ok(result);
    }
} 